﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AllAppForms.aspx.cs" Inherits="CRMWeb.Pages.AllAppForms" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <table id="dgAllApplications" style="width: auto;" autorowheight="true"
        rownumbers="true" fitcolumns="true" singleselect="true">
        <thead>
            <tr>
                <th field="FormID" hidden="true">Form-ID</th>
                <th field="cdate" width="50">Date Created</th>
                <th field="Age" width="40" data-options="formatter:calculateAge">Age</th>
                <th field="DesiredAmount" width="30">Desired Amount </th>
                <th field="Assets" width="40">Assets</th>
                <th field="ClientName" width="50">Name</th>
                <th field="comesfrom" width="50">Came From</th>

                <th field="easyViewLink" width="30" data-options="formatter:easyViewForm"></th>
                <th field="verifiedFormLink" width="30" data-options="formatter:linkToVerifiedForm"></th>
            </tr>
        </thead>
    </table>
    <script type="text/javascript">

        function linkToVerifiedForm(value, row) {
            //var applicationId = row.app_id;
            return "<a target='_blank' href='/Pages/Application_Form.aspx?verified=1&id=" + row.FormID + '&comesfrom=' + row.comesfrom + "'>Final Verification</a>";
        }
        function easyViewForm(val, row) {
            return "<a target='_blank' href='/pages/Application_Form.aspx?verified=0&id=" + row.FormID + '&comesfrom=' + row.comesfrom + "'>Easy View</a>";
        }
        function formatDate(value, row) {
            if (value == null)
                return '';
            var date = new Date(value);
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            var d = date.getDate();
            return (d < 10 ? ('0' + d) : d) + '/' + (m < 10 ? ('0' + m) : m) + '/' + y;
        }
        function calculateAge(value, row) {
            if (value == null)
                return '';
            var date = new Date(value);
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            var d = date.getDate();
            return getAge((m < 10 ? ('0' + m) : m) + '/' + (d < 10 ? ('0' + d) : d) + '/' + y);
        }
        $(document).ready(function () {

            $('#dgAllApplications').datagrid({
                url: '/WebServices/ApplicationInfo.ashx?method=BindApplicationForm&app_id=' + getQuerystring('app_id', ''),
                onDblClickRow: function (index, rowdata) {
                    var newTab = window.open('/pages/Application_Form.aspx?verified=0&id=' + rowdata.FormID + '&comesfrom=' + rowdata.comesfrom, '_blank');
                    newTab.focus();
                }
            });
        });
    </script>
</body>
</html>
